#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int get_group(char c)
{
    if (c == 'b' || c == 'd' || c == 'p' || c == 'q')
    {
        return 1;
    }
    if (c == 'n' || c == 'u') 
    {
        return 2;
    }
    return 0; 
}

int main() 
{
    int T;
    scanf_s("%d", &T);

    for (int i = 0; i < T; i++) 
    {
        char s[100001]; 
        scanf_s("%s", s);
        int len = strlen(s);

        int new_capacity = len * 2 + 1;
        char* new_str = (char*)malloc(new_capacity * sizeof(char));
        int new_len = 0;

        for (int j = 0; j < len; j++)
        {
            if (s[j] == 'w') 
            {
                new_str[new_len++] = 'v';
                new_str[new_len++] = 'v';
            }
            else if (s[j] == 'm') 
            {
                new_str[new_len++] = 'n';
                new_str[new_len++] = 'n';
            }
            else 
            {
                new_str[new_len++] = s[j];
            }
        }
        new_str[new_len] = '\0'; 

        if (new_len == 0) 
        {
            printf("YES\n");
            free(new_str);
            continue;
        }

        int left = 0, right = new_len - 1;
        int valid = 1; 
        while (left < right) 
        {
            char c1 = new_str[left];
            char c2 = new_str[right];
            int g1 = get_group(c1);
            int g2 = get_group(c2);

            if (g1 == 0 && g2 == 0) 
            {
                if (c1 != c2)
                {
                    valid = 0;
                    break;
                }
            }
            else if (g1 == g2)
            {

            }
            else 
            {
                valid = 0;
                break;
            }

            left++;
            right--;
        }

        if (valid) 
        {
            printf("YES\n");
        }
        else 
        {
            printf("NO\n");
        }

        free(new_str);
    }

    return 0;
}